# Copyright (c) Zhirnov Andrey. For more information see 'LICENSE'

file( GLOB_RECURSE CPP_SOURCES "*.*" )

if (ANDROID)
	add_library( "TestLauncher" SHARED ${CPP_SOURCES} )

	if (TARGET "TestsBase")
		add_dependencies( "TestLauncher" "TestsBase" )
	endif()
	if (TARGET "TestsScripting")
		add_dependencies( "TestLauncher" "TestsScripting" )
	endif()
	if (TARGET "TestsThreading")
		add_dependencies( "TestLauncher" "TestsThreading" )
	endif()
	if (TARGET "TestsNetworking")
		add_dependencies( "TestLauncher" "TestsNetworking" )
	endif()
	if (TARGET "TestsSerializing")
		add_dependencies( "TestLauncher" "TestsSerializing" )
	endif()
	if (TARGET "TestsPlatform")
	#	add_dependencies( "TestLauncher" "TestsPlatform" )
	endif()
	if (TARGET "TestsGraphics")
		add_dependencies( "TestLauncher" "TestsGraphics" )
	endif()
	if (TARGET "TestsGraphicsHL")
		add_dependencies( "TestLauncher" "TestsGraphicsHL" )
	endif()
	if (TARGET "TestsECS-st")
		add_dependencies( "TestLauncher" "TestsECS-st" )
	endif()
	if (TARGET "TestsVFS")
		add_dependencies( "TestLauncher" "TestsVFS" )
	endif()
	if (TARGET "TestsHuLang")
		add_dependencies( "TestLauncher" "TestsHuLang" )
	endif()

	if (TARGET "TestsAtlasTools")
		add_dependencies( "TestLauncher" "TestsAtlasTools" )
	endif()
	if (TARGET "TestsGeometryTools")
		add_dependencies( "TestLauncher" "TestsGeometryTools" )
	endif()

	if (TARGET "PerfBase")
		add_dependencies( "TestLauncher" "PerfBase" )
	endif()
	if (TARGET "PerfThreading")
		add_dependencies( "TestLauncher" "PerfThreading" )
	endif()

else()
	set( ANDROID_SRC_PATH "${MAIN_SOURCE_DIR}/android/test/src/main" )
	if (NOT EXISTS "${ANDROID_SRC_PATH}")
		message( FATAL_ERROR "Android source is not exists in ${ANDROID_SRC_PATH}" )
	endif()
	file( GLOB_RECURSE ANDROID_SOURCES "${ANDROID_SRC_PATH}/*.*" )
	list( APPEND ANDROID_SOURCES "${ANDROID_SRC_PATH}/../../build.gradle" )

	add_executable( "TestLauncher" ${CPP_SOURCES} ${ANDROID_SOURCES} )

	source_group( "Apk" FILES ${ANDROID_SOURCES} )
	set_source_files_properties( ${ANDROID_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE )
endif()

source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${CPP_SOURCES} )
target_link_libraries( "TestLauncher" PUBLIC "Platform" )
set_property( TARGET "TestLauncher" PROPERTY FOLDER "Engine/Tests" )
